﻿using MOKA.TPM.Utility.Const;
using SqlSugar;
using System.ComponentModel.DataAnnotations;

namespace MOKA.TPM.Entity;

/// <summary>
/// 设备点检任务
/// </summary>
[Tenant(TPMConst.TPMConfigId)]
[SugarTable("CheckupTask", "设备点检任务")]
public class CheckupTask
{
    /// <summary>
    /// 计划ID
    /// </summary>
    [SugarColumn(ColumnName = "Id", ColumnDescription = "计划ID", IsPrimaryKey = true)]
    public Guid Id { get; set; }

    /// <summary>
    /// TPM设备分组
    /// </summary>
    [SugarColumn(ColumnName = "TPMDeviceGroupId", ColumnDescription = "TPM设备分组")]
    public Guid TPMDeviceGroupId { get; set; }

    /// <summary>
    /// 任务名称
    /// </summary>
    [SugarColumn(ColumnName = "TaskName", ColumnDescription = "任务名称", Length = 100)]
    [Required, MaxLength(100)]
    public string TaskName { get; set; } = string.Empty;

    /// <summary>
    /// 任务所属区域
    /// </summary>
    [SugarColumn(ColumnName = "Area", ColumnDescription = "任务所属区域")]
    public Guid Area { get; set; }

    /// <summary>
    /// 点检周期
    /// </summary>
    [SugarColumn(ColumnName = "CheckupCycle", ColumnDescription = "点检周期")]
    public Guid CheckupCycle { get; set; }

    /// <summary>
    /// 当前周期
    /// </summary>
    [SugarColumn(ColumnName = "CurrentCycle", ColumnDescription = "当前周期", Length = 50)]
    [Required, MaxLength(50)]
    public string CurrentCycle { get; set; } = string.Empty;

    /// <summary>
    /// 设备数量
    /// </summary>
    [SugarColumn(ColumnName = "DeviceQty", ColumnDescription = "设备数量")]
    public int DeviceQty { get; set; }

    /// <summary>
    /// 到期日期
    /// </summary>
    [SugarColumn(ColumnName = "TaskDate", ColumnDescription = "到期日期")]
    public DateTime TaskDate { get; set; }

    /// <summary>
    /// 接收人
    /// </summary>
    [SugarColumn(ColumnName = "ReceiveMan", ColumnDescription = "接收人", Length = 20)]
    [MaxLength(20)]
    public string? ReceiveMan { get; set; }

    /// <summary>
    /// 接收日期
    /// </summary>
    [SugarColumn(ColumnName = "ReceiveTime", ColumnDescription = "接收日期")]
    public DateTime? ReceiveTime { get; set; }

    /// <summary>
    /// 计划开始日期
    /// </summary>
    [SugarColumn(ColumnName = "PlanDateFrom", ColumnDescription = "计划开始日期")]
    public DateTime? PlanDateFrom { get; set; }

    /// <summary>
    /// 计划结束日期
    /// </summary>
    [SugarColumn(ColumnName = "PlanDateEnd", ColumnDescription = "计划结束日期")]
    public DateTime? PlanDateEnd { get; set; }

    /// <summary>
    /// 任务完成日期
    /// </summary>
    [SugarColumn(ColumnName = "FinishTime", ColumnDescription = "任务完成日期")]
    public DateTime? FinishTime { get; set; }

    /// <summary>
    /// 当前状态
    /// </summary>
    [SugarColumn(ColumnName = "TaskStatus", ColumnDescription = "当前状态")]
    public Guid? TaskStatus { get; set; }

    /// <summary>
    /// 确认人
    /// </summary>
    [SugarColumn(ColumnName = "ConfirmMan", ColumnDescription = "确认人", Length = 20)]
    [MaxLength(20)]
    public string? ConfirmMan { get; set; }

    /// <summary>
    /// 确认时间
    /// </summary>
    [SugarColumn(ColumnName = "ConfirmTime", ColumnDescription = "确认时间")]
    public DateTime? ConfirmTime { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    [SugarColumn(ColumnName = "Remark", ColumnDescription = "备注", Length = 200)]
    [MaxLength(200)]
    public string? Remark { get; set; }

    /// <summary>
    /// 创建用户
    /// </summary>
    [SugarColumn(ColumnName = "CreateUser", ColumnDescription = "创建用户", Length = 20)]
    [Required, MaxLength(20)]
    public string CreateUser { get; set; } = string.Empty;

    /// <summary>
    /// 创建时间
    /// </summary>
    [SugarColumn(ColumnName = "CreateTime", ColumnDescription = "创建时间")]
    public DateTime CreateTime { get; set; }

    /// <summary>
    /// 更新用户
    /// </summary>
    [SugarColumn(ColumnName = "UpdateUser", ColumnDescription = "更新用户", Length = 20)]
    [MaxLength(20)]
    public string? UpdateUser { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    [SugarColumn(ColumnName = "UpdateTime", ColumnDescription = "更新时间")]
    public DateTime? UpdateTime { get; set; }

    /// <summary>
    /// TPMDeviceGroupId (TPM设备分组) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(TPMDeviceGroupId), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_TPMDeviceGroupId { get; set; }

    /// <summary>
    /// Area (任务所属区域) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(Area), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_Area { get; set; }

    /// <summary>
    /// CheckupCycle (点检周期) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(CheckupCycle), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_CheckupCycle { get; set; }

    /// <summary>
    /// ReceiveMan (接收人) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(ReceiveMan), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_ReceiveMan { get; set; }

    /// <summary>
    /// TaskStatus (当前状态) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(TaskStatus), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_TaskStatus { get; set; }

    /// <summary>
    /// ConfirmMan (确认人) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(ConfirmMan), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_ConfirmMan { get; set; }

    /// <summary>
    /// CreateUser (创建用户) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(CreateUser), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_CreateUser { get; set; }

    /// <summary>
    /// UpdateUser (更新用户) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(UpdateUser), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_UpdateUser { get; set; }

    /// <summary>
    /// 子表：点检设备
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(Checkup.CheckupTaskId))]//一对多
    public List<Checkup> Checkups { get; set; }
}